<!DOCTYPE html>
<!--
  ~ Date：12/12/18 11:45 AM 
  ~ Author: guomw
  ~
  -->

<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN">


<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>新增运费模板</title>
    <link rel="stylesheet" href="http://resali.huobanplus.com/cdn/normalize/4.2.0/normalize.css"/>
    <link rel="stylesheet" href="../../resource/css/freight.css" th:href="@{/resource/css/freight.css}"/>

    <link href="../../resource/css/plugins/sweetalert/sweetalert.css?v=4.0.0" rel="stylesheet" th:href="@{/resource/css/plugins/sweetalert/sweetalert.css?v=4.0.0}"/>
<style>
    .mixture input{
        width: 50px;
    }
</style>
</head>
<body style="background-color: #fff;">
<div id="content" th:object="${freightTemplate}">
    <h4>新增运费模板</h4>

    <div class="button">
        <button th:onclick="|javascript:window.location.href='@{/freight/list(proType=${proType})}'|" class="btn" type="button">返回运费列表</button>
    </div>

    <p style="height: 20px;"></p>

    <form name="tplForm" id="tplForm">
        <div class="from-group">
            <label class="label"><span style="color: #CA030A;">*</span> 模板名称：</label>
            <input title="模板名称" type="text" name="name" th:value="*{name}" validate-place="nameMsg" validate="required"/>
            <span id="nameMsg" style="margin-left: 10px;"></span>
        </div>
        <div class="from-group">
            <label class="label">是否包邮：</label>

            <div class="check-group">
                <p><input class="input-check" type="radio" name="Is_ShippingFree" value="0"
                          th:checked="${freightTemplate == null} or *{isShippingFree==0}" checked="checked"/>买家承担运费</p>

                <p><input class="input-check" type="radio" name="Is_ShippingFree" th:checked="*{isShippingFree==1}" value="1"/>卖家承担运费</p>
            </div>
        </div>
        <div class="notFree" th:styleappend="*{isShippingFree==0}?'displya:block':'display:none'">
            <div class="from-group notFree">
                <label class="label">计价方式：</label>

                <div class="check-group">
                    <p><input class="input-check" type="radio" name="valuationWay" value="0"
                              th:checked="${freightTemplate == null} or *{valuationWay==0}" checked="checked"/>按件计价</p>

                    <!--<p><input class="input-check" type="radio" name="valuationWay" th:checked="*{valuationWay==1}" value="1"/>按重计价（g）</p>-->
                </div>
            </div>
            <div class="from-group notFree">
                <label class="label"><span style="color: #CA030A;">*</span> 运送方式：</label>

                <p class="text-group gray">除指定地区外，其余地区的运费采用“默认运费”。至少要选择一项运送方式。</p>
            </div>

            <div class="from-group notFree" th:each="deliveryType:${deliveryTypes}">
                <div>
                    <p class="text-group" style="padding-left: 124px;">
                        <input class="chkDeliveryType" type="checkbox" name="deliveryType" value="0" th:value="${deliveryType.code}"/>
                        <span th:text="${deliveryType.desc}">快递</span>
                    </p>

                    <div style="display: none;" class="detailSet">
                        <p class="text-group mixture gray">
                            <input type="hidden" name="detailId0" id="default0"
                                   th:name="'detailId'+${deliveryType.code}" th:id="'def_detailId'+${deliveryType.code}" value="0"/>
                            <input type="hidden" name="areaIdGroup0" th:name="'areaIdGroup'+${deliveryType.code}"/>
                            <input type="hidden" name="areaDesc0" th:name="'areaDesc'+${deliveryType.code}"/>
                            <input type="hidden" name="isDefault0" th:name="'isDefault'+${deliveryType.code}" value="1"/>

                            <span class="char">默认运费</span>
                            <input type="text" value="1" name="firstItem0" validate="required" title="首件" class="num_int"
                                   th:attrappend="validate-place='def_firstItem_msg'+${deliveryType.code}"
                                   th:name="'firstItem'+${deliveryType.code}" th:id="'def_firstItem'+${deliveryType.code}"/>
                            <span class="char"><span class="unit">件</span>内，</span>
                            <input type="text" name="firstFreight0" validate="required" title="首费" class="num_float"
                                   th:attrappend="validate-place='def_firstFreight_msg'+${deliveryType.code}"
                                   th:name="'firstFreight'+${deliveryType.code}" th:id="'def_firstFreight'+${deliveryType.code}"/>
                            <span class="char">元，</span>
                            <span class="char">每增加</span>
                            <input type="text" value="1" name="nextItem0" validate="required" title="续件" class="num_int"
                                   th:attrappend="validate-place='def_nextItem_msg'+${deliveryType.code}"
                                   th:name="'nextItem'+${deliveryType.code}" th:id="'def_nextItem'+${deliveryType.code}"/>
                            <span class="char"><span class="unit">件</span>，</span>
                            <span class="char">增加运费</span>
                            <input type="text" name="nextFreight0" validate="required" title="续费" class="num_float"
                                   th:attrappend="validate-place='def_nextFreight_msg'+${deliveryType.code}"
                                   th:name="'nextFreight'+${deliveryType.code}" th:id="'def_nextFreight'+${deliveryType.code}"/>
                            <span class="char">元，满</span>
                            <input type="text" name="nextFreight0" validate="required" value="5" title="免邮条件" class="num_int"
                                   th:attrappend="validate-place='def_freeFreight_msg'+${deliveryType.code}"
                                   th:name="'freeFreight'+${deliveryType.code}" th:id="'def_freeFreight'+${deliveryType.code}"/>
                            <span class="char">件免邮</span>
                        </p>

                        <div style="width: 1000px;">
                            <p style="margin-left: 178px;width: 115px;float: left;" th:id="'def_firstItem_msg'+${deliveryType.code}">&nbsp;&nbsp; </p>

                            <p style="width: 138px;float: left;" th:id="'def_firstFreight_msg'+${deliveryType.code}">&nbsp;&nbsp; </p>

                            <p style="width: 138px;float: left;" th:id="'def_nextItem_msg'+${deliveryType.code}">&nbsp;&nbsp; </p>

                            <p style="margin-left: 15px;width: 110px;float: left;" th:id="'def_nextFreight_msg'+${deliveryType.code}"> &nbsp;&nbsp;</p>

                            <p style="width: 138px;float: left;" th:id="'def_freeFreight_msg'+${deliveryType.code}"> &nbsp;&nbsp;</p>
                        </div>


                        <table class="addTpl" cellspacing="0">
                            <thead>
                            <tr>
                                <th>运送到</th>
                                <th>首<span class="unit">件</span></th>
                                <th>运费(元)</th>
                                <th>续<span class="unit">件</span></th>
                                <th>续费(元)</th>
                                <th>满n件免邮</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="freightDetail:${freightTemplate.designatedDetails(deliveryType)}">
                                <td>
                                    <input type="hidden" name="detailId{deliveryType}" value="0" th:value="${freightDetail.id}" th:name="'detailId'+${deliveryType.code}"/>
                                    <input type="hidden" name="areaIdGroup{deliveryType}"
                                           th:id="'areaIdGroup_'+${deliveryType.code}+'_'+${freightDetailStat.index}"
                                           th:name="'areaIdGroup'+${deliveryType.code}" th:value="${freightDetail.areaIdGroup}"/>
                                    <input type="hidden" th:name="'isDefault'+${deliveryType.code}" name="isDefault{deliveryType}" value="0"/>

                                    <div class="city-picker">
                                        <input readonly="readonly" th:value="${freightDetail.areaDesc}" type="text" placeholder="请选择省/市" title="配送区域"
                                               th:attrappend="validate-place='areaDesc_msg_'+${deliveryType.code}+'_'+${freightDetailStat.index}"
                                               th:id="'areaDesc_'+${deliveryType.code}+'_'+${freightDetailStat.index}"
                                               name="areaDesc{deliveryType}" th:name="'areaDesc'+${deliveryType.code}" class="input-area" validate="required"
                                               th:onclick="|freightHandler.selectRegion('${deliveryType.code}',${freightDetailStat.index})|" onclick="freightHandler.selectRegion()"/>
                                        <br/><br/>
                                        <span th:id="'areaDesc_msg_'+${deliveryType.code}+'_'+${freightDetailStat.index}"></span>
                                    </div>
                                </td>
                                <td class="center">
                                    <input type="text" value="1" name="firstItem{deliveryType}" title="首件"
                                           th:value="${freightDetail.firstItem}" th:name="'firstItem'+${deliveryType.code}"
                                           th:attrappend="validate-place='firstItem_msg_'+${deliveryType.code}+'_'+${freightDetailStat.index}"
                                           class="input-text input-mini for-shipping-change num_int" validate="required"/>
                                    <br/><br/>
                                    <span th:id="'firstItem_msg_'+${deliveryType.code}+'_'+${freightDetailStat.index}"></span>
                                </td>
                                <td class="center">
                                    <input type="text" name="firstFreight{deliveryType}" title="首费"
                                           th:value="${freightDetail.firstFreight}" th:name="'firstFreight'+${deliveryType.code}"
                                           th:attrappend="validate-place='firstFreight_msg_'+${deliveryType.code}+'_'+${freightDetailStat.index}"
                                           class="input-text input-mini num_float" validate="required"/>
                                    <br/><br/>
                                    <span th:id="'firstFreight_msg_'+${deliveryType.code}+'_'+${freightDetailStat.index}"></span>
                                </td>
                                <td class="center">
                                    <input type="text" value="1" name="nextItem{deliveryType}" title="续件"
                                           th:value="${freightDetail.nextItem}" th:name="'nextItem'+${deliveryType.code}"
                                           th:attrappend="validate-place='nextItem_msg_'+${deliveryType.code}+'_'+${freightDetailStat.index}"
                                           class="input-text input-mini for-shipping-change num_int" validate="required"/>
                                    <br/><br/>
                                    <span th:id="'nextItem_msg_'+${deliveryType.code}+'_'+${freightDetailStat.index}"></span>
                                </td>
                                <td class="center">
                                    <input type="text" name="nextFreight{deliveryType}" title="续费"
                                           th:value="${freightDetail.nextFreight}" th:name="'nextFreight'+${deliveryType.code}"
                                           th:attrappend="validate-place='nextFreight_msg_'+${deliveryType.code}+'_'+${freightDetailStat.index}"
                                           class="input-text input-mini num_float" validate="required"/>
                                    <br/><br/>
                                    <span th:id="'nextFreight_msg_'+${deliveryType.code}+'_'+${freightDetailStat.index}"></span>
                                </td>
                                <td class="center">
                                    <input type="text" name="freeFreight{deliveryType}" title="免邮条件"
                                           th:value="${freightDetail.freeFreightItem}" th:name="'freeFreight'+${deliveryType.code}"
                                           th:attrappend="validate-place='freeFreight_msg_'+${deliveryType.code}+'_'+${freightDetailStat.index}"
                                           class="input-text input-mini num_float" validate="required" placeholder="满n件免邮"/>
                                    <br/><br/>
                                    <span th:id="'freeFreight_msg_'+${deliveryType.code}+'_'+${freightDetailStat.index}"></span>
                                </td>
                                <td class="center">
                                    <a class="areaFeeDelete" href="javascript:;">删除</a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <p class="addOne">
                            <a style="cursor: pointer;" th:onclick="|freightHandler.addRule(this,'${deliveryType.code}')|" onclick="freightHandler.addRule(this,0);" class="addRule">为指定地区城市设置运费</a>
                        </p>
                    </div>
                </div>
            </div>
        </div>
        <div class="btn-group" style="margin: 5px;">
            <input class="btn submit" id="btn_save" type="button" onclick="freightHandler.submitForm();" value="保存"/>
        </div>
    </form>
</div>

</body>
<script src="http://cdn.viptool.cn/lib/jquery/2.2.4/jquery.min.js"></script>
<script src="../../resource/js/plugins/sweetalert/sweetalert.min.js" th:src="@{/resource/js/plugins/sweetalert/sweetalert.min.js}"></script>
<script src="../../resource/js/plugins/hot/Jquery.util.js" th:src="@{/resource/js/plugins/hot/Jquery.util.js?201812012051}"></script>
<link href="../../resource/lib/jBox/Skins/Green/jbox.css" th:href="@{/resource/lib/jBox/Skins/Green/jbox.css}" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../resource/lib/jBox/jquery.jBox-2.3.min.js" th:src="@{/resource/lib/jBox/jquery.jBox-2.3.min.js}"></script>
<script type="text/javascript" src="../../resource/lib/regionNode.js" th:src="@{/resource/lib/regionNode.js}"></script>
<script src="http://resali.huobanplus.com/cdn/layer/2.3/layer.js" type="text/javascript"></script>

<script type="text/javascript" th:inline="javascript">
    var defaultDetails = /*[[${defaultDetailJson}]]*/ [];
    var templateId = /*[[${templateId}]]*/ 0;
    var ajaxUrl = /*[[@{/freight/ajax/saveTemplate}]]*/ "";
    var listUrl = /*[[@{/freight/list(proType=${proType})}]]*/ "";
    var proType = /*[[${proType}]]*/ 0;
</script>

<script type="text/javascript">
    /*<![CDATA[*/
    var regionDialog;
    var freightHandler = {
        pageInit: function () {
            $.each(defaultDetails, function (o, item) {
                //设置选中
                var $chkDeliveryType = $("input[name=deliveryType][value=" + item.deliveryType + "]");
                $chkDeliveryType.attr("checked", "checked");
                $chkDeliveryType.parent().parent().find('div').show();
                //填充默认
                $("#def_detailId" + item.deliveryType).val(item.id);
                $("#def_firstItem" + item.deliveryType).val(item.firstItem);
                $("#def_firstFreight" + item.deliveryType).val(item.firstFreight);
                $("#def_nextItem" + item.deliveryType).val(item.nextItem);
                $("#def_nextFreight" + item.deliveryType).val(item.nextFreight);
                $("#def_freeFreight" + item.deliveryType).val(item.freeFreight);
            });
        },
        addRule: function (obj, deliveryType) {
            var trCount = $(obj).parent().parent().find('tbody').find('tr').length;
            var tr = $("#detail_template").html();
            tr = tr.replace(/{deliveryType}/g, deliveryType);
            tr = tr.replace(/{stateIndex}/g, trCount);
            $(obj).parent().parent().find('tbody').append(tr);
        },
        selectRegion: function (deliveryType, stateIndex) {
            var dialogHtml = regionTemplate;
            var areaIdGroup = $("#areaIdGroup_" + deliveryType + "_" + stateIndex).val();
            dialogHtml = dialogHtml.replace("{deliveryType}", deliveryType);
            dialogHtml = dialogHtml.replace("{stateIndex}", stateIndex);
            var $temp = $('<div></div>');
            $temp.html(dialogHtml);

            var areaIdGroupArray = areaIdGroup.substring(1, areaIdGroup.length - 1).split('|');
            $.each(areaIdGroupArray, function (o, areaId) {
                $temp.find("input[name=chkArea][value=" + areaId + "]").attr("checked", "checked");
            });

            regionDialog = layer.open({
                type: 1,
                area: ['720px', '400px'],
                content: $temp.html()
            });
        },
        submitForm: function () {
            validateHandler.validate(function () {
                var chkDeliveryTypes = $("input[name=deliveryType]:checked");
                var isShippingFree = $("input[name=Is_ShippingFree]:checked").val();
                if (chkDeliveryTypes.length == 0 && isShippingFree == 0) {

                    return;
                }

                var name = $("input[name=name]").val();

                var valuationWay = $("input[name=valuationWay]:checked").val();
                var freightTemplateDetails = [];

                $("input[name=deliveryType]:checked").each(function () {
                    var deliveryType = $(this).val();
                    var detailIdDoms = $("input[name=detailId" + deliveryType + "]");
                    var isDefaultDoms = $("input[name=isDefault" + deliveryType + "]");
                    var areaIdGroupDoms = $("input[name=areaIdGroup" + deliveryType + "]");
                    var areaDescDoms = $("input[name=areaDesc" + deliveryType + "]");
                    var firstItemDoms = $("input[name=firstItem" + deliveryType + "]");
                    var firstFreightDoms = $("input[name=firstFreight" + deliveryType + "]");
                    var nextItemDoms = $("input[name=nextItem" + deliveryType + "]");
                    var nextFreightDoms = $("input[name=nextFreight" + deliveryType + "]");
                    var freeFreightDoms = $("input[name=freeFreight" + deliveryType + "]");
                    detailIdDoms.each(function (index, element) {
                        var freightTemplateDetail = {
                            id: element.value,
                            deliveryType: deliveryType,
                            isDefault: isDefaultDoms[index].value,
                            areaDesc: areaDescDoms[index].value,
                            areaIdGroup: areaIdGroupDoms[index].value,
                            firstItem: firstItemDoms[index].value,
                            firstFreight: firstFreightDoms[index].value,
                            nextItem: nextItemDoms[index].value,
                            nextFreight: nextFreightDoms[index].value,
                            freeFreight:freeFreightDoms[index].value
                        };
                        freightTemplateDetails.push(freightTemplateDetail);
                    });
                });

                var requestData = {
                    id: templateId,
                    name: name,
                    isShippingFree: isShippingFree,
                    valuationWay: valuationWay,
                    detailJson: JSON.stringify(freightTemplateDetails),
                    proType: proType
                };
                hotUtil.loading.show();
                hotUtil.ajaxCall(ajaxUrl, requestData, function (ret) {
                    hotUtil.loading.close();
                    if (ret.resultCode == 2000) {
                        hotUtil.alert("保存成功", function () {
                            window.location.href = listUrl;
                        }, "success")

                    } else {
                        swal("保存失败！", ret.resultMsg, "error");
                    }
                });
            }, function () {
            });
        }
    };

    var validateHandler = {
        validate: function (successHandler, errorHandler) {
            var errorCount = 0;
            $(".val-error-msg").remove();
            $(".validate-error").removeClass("validate-error");
            $("input[validate=required]").each(function () {
                var element = $(this);
                if (!validateHandler.validateElement(element)) {
                    errorCount++;
                }
            });
            errorCount <= 0 ? successHandler() : errorHandler();
        },
        validateElement: function (element) {
            if (element.is(":hidden")) {
                return true;
            }
            var validatePlace = element.attr("validate-place");

            if ($.trim(element.val()).length == 0) {
                //开始验证
                element.addClass("validate-error");

                var error = $('<span style="color: #CA030A;" class="val-error-msg"></span>');
                var errorMsg = $.trim(element.attr("validate-msg"));
                if (errorMsg.length == 0) {
                    errorMsg = "请输入" + element.attr("title");
                }
                error.html(errorMsg);

                if (hotUtil.IsUndefined(validatePlace)) {
                    element.parent().find(".val-error-msg").remove();
                    error.appendTo(element.parent());
                } else {
                    $("#" + validatePlace).html(error);
                }
                return false;
            } else {
                element.removeClass("validate-error");
                if (hotUtil.IsUndefined(validatePlace)) {
                    element.parent().find(".val-error-msg").remove();
                } else {
                    $("#" + validatePlace).html("&nbsp;&nbsp;&nbsp;&nbsp;");
                }
                return true;
            }
        }
    };

    $(function () {
        freightHandler.pageInit();
        changeUnit();

        $('.addTpl').on('click', '.areaFeeDelete', function () {
            $(this).parentsUntil('tbody').remove();
        });

        $(".chkDeliveryType").change(function () {
            if ($(this).is(':checked')) {
                $(this).parent().parent().find('div').show();
            } else {
                $(this).parent().parent().find('div').hide();
            }
        });

        $("input[name=valuationWay]").change(function () {
            changeUnit();
        });

        $("input[name=Is_ShippingFree]").change(function () {
            if ($("input[name=Is_ShippingFree]:checked").val() == "0") {
                $(".notFree").show();
            } else {
                $(".notFree").hide();
            }
        });

        regionHandler.initRegion();
    });

    $(document).on('keydown', ".num_float", function () {
        hotUtil.CertainNumberContainPoint(event);
    });

    $(document).on('keydown', ".num_int", function () {
        hotUtil.CertainNumber(event);
    });

    function changeUnit() {
        if ($("input[name=valuationWay]:checked").val() == "0") {
            $(".unit").html("件");
        } else {
            $(".unit").html("重(g)");
        }
    }

    /*]]>*/
</script>
<script type="text/javascript">
    $(document).on('click', '.caret', function () {
        var $dom = $(this).parents('.area-select-head').next();
        $dom.toggle();
        if ($dom.is(':hidden')) {
            $(this).parents('.area-select-wrapper').removeClass('selected');
        } else {
            $(this).parents('.area-select-wrapper').addClass('selected');
        }
    });
    $(document).on('click', '.close', function () {
        $(this).parents('.area-select-body').hide();
        $(this).parents('.area-select-wrapper').removeClass('selected');
    });

    $(document).on('click', '.J_Submit', function () {
        var areaDesc = regionHandler.getAreaDesc();
        var areaIdGroup = regionHandler.getAreaIdGroup();
        if (areaIdGroup.length == 0) {
            $.jBox.tip("请选择地区");
            return;
        }
        var deliveryType = $("#reg_hd_deliveryType").val();
        var stateIndex = $("#reg_hd_stateIndex").val();

        $("#areaIdGroup_" + deliveryType + "_" + stateIndex).val(areaIdGroup);
        $("#areaDesc_" + deliveryType + "_" + stateIndex).val(areaDesc);

        layer.close(regionDialog);
    });
    $(document).on('click', '.J_cancel', function () {
        layer.close(regionDialog);
    });

    var regionTemplate;

    var regionHandler = {
        initRegion: function () {
            var provinces = regionProvider.getByPId(0);
            var pHtml = "";
            $.each(provinces, function (o, province) {
                var pTempHtml = $("#province_template").html();
                pTempHtml = pTempHtml.replace(/{id}/g, province.id);
                pTempHtml = pTempHtml.replace(/{provinceName}/g, province.name);

                //如果不是是直辖市,找下一级
                var cHtml = "";
                var cities = regionProvider.getByPId(province.id);
                $.each(cities, function (o, city) {
                    var cTempHtml = $("#city_template").html();
                    cTempHtml = cTempHtml.replace(/{id}/g, city.id);
                    cTempHtml = cTempHtml.replace("{cityName}", city.name);
                    cTempHtml = cTempHtml.replace("{pId}", city.pId);
                    cHtml += cTempHtml;
                });
                pTempHtml = pTempHtml.replace("{cities}", cHtml);
                pTempHtml = pTempHtml.replace("{childCount}", cities.length);
                pTempHtml = pTempHtml.replace("{childrenShow}", cities.length == 0 ? '' : '<span class="caret"></span>');
                pHtml += pTempHtml;
            });

            var regions = $('<ul class="area_content"></ul>');
            regions.html(pHtml);
            $("#region_template").prepend(regions);

            regionTemplate = $('#region_template').html();
            $("#region_template").remove();
        },
        proChange: function (chkRegion) {
            var $chkRegion = $(chkRegion);
            if ($chkRegion.is(':checked')) {
                $("input[parent-id=" + $chkRegion.val() + "]").attr("checked", "checked");
            } else {
                $("input[parent-id=" + $chkRegion.val() + "]").removeAttr("checked");
            }
        },
        cityChange: function (chkCity) {
            var $chkCity = $(chkCity);
            var pId = $chkCity.attr("parent-id")
            var $chkCities = $("input[parent-id=" + pId + "]:checked");
            if ($chkCities.length > 0) {
                $("#J_Province_" + pId).attr("checked", "checked");
            } else {
                $("#J_Province_" + pId).removeAttr("checked");
            }
        },
        getAreaDesc: function () {
            var areaDesc = "";
            $(".J_Province:checked").each(function () {
                areaDesc += $(this).attr("title") + ",";
            });
            return areaDesc.substring(0, areaDesc.length - 1);
        },
        getAreaIdGroup: function () {
            var areaIdGroup = "|";
            $("input[name=chkArea]:checked").each(function () {
                areaIdGroup += $(this).val() + '|';
            });
            return areaIdGroup;
        }
    }
</script>
</html>
<script type="text/html" id="detail_template">
    <tr>
        <td>
            <input type="hidden" name="detailId{deliveryType}" value="0"/>
            <input type="hidden" name="areaIdGroup{deliveryType}" value="0" id="areaIdGroup_{deliveryType}_{stateIndex}"/>
            <input type="hidden" name="isDefault{deliveryType}" value="0"/>

            <div class="city-picker">
                <input readonly="readonly" type="text" placeholder="请选择省/市" title="配送区域"
                       validate-place="areaDesc_msg_{deliveryType}_{stateIndex}"
                       id="areaDesc_{deliveryType}_{stateIndex}"
                       name="areaDesc{deliveryType}" class="input-area" validate="required"
                       onclick="freightHandler.selectRegion('{deliveryType}',{stateIndex})"/>
                <br/><br/>
                <span id="areaDesc_msg_{deliveryType}_{stateIndex}"></span>
            </div>
        </td>
        <td class="center">
            <input type="text" value="1" style="width: 50px;" name="firstItem{deliveryType}" title="首件"
                   validate-place="firstItem_msg_{deliveryType}_{stateIndex}"
                   class="input-text input-mini for-shipping-change num_int" validate="required"/>
            <br/><br/>
            <span id="firstItem_msg_{deliveryType}_{stateIndex}"></span>
        </td>
        <td class="center">
            <input type="text"  style="width: 50px;"  name="firstFreight{deliveryType}" title="首费"
                   validate-place="firstFreight_msg_{deliveryType}_{stateIndex}"
                   class="input-text input-mini num_float" validate="required"/>
            <br/><br/>
            <span id="firstFreight_msg_{deliveryType}_{stateIndex}"></span>
        </td>
        <td class="center">
            <input type="text"  style="width: 50px;"  value="1" name="nextItem{deliveryType}" title="续件"
                   validate-place="nextItem_msg_{deliveryType}_{stateIndex}"
                   class="input-text input-mini for-shipping-change num_int" validate="required"/>
            <br/><br/>
            <span id="nextItem_msg_{deliveryType}_{stateIndex}"></span>
        </td>
        <td class="center">
            <input type="text"  style="width: 50px;"  name="nextFreight{deliveryType}" title="续费"
                   validate-place="nextFreight_msg_{deliveryType}_{stateIndex}"
                   class="input-text input-mini num_float" validate="required"/>
            <br/><br/>
            <span id="nextFreight_msg_{deliveryType}_{stateIndex}"></span>
        </td>

        <td class="center">
            <input type="text"  style="width: 50px;"  name="freeFreight{deliveryType}" title="免邮条件"
                   validate-place="freeFreight_msg_{deliveryType}_{stateIndex}"
                   class="input-text input-mini num_float" validate="required"/>
            <br/><br/>
            <span id="freeFreight_msg_{deliveryType}_{stateIndex}"></span>
        </td>


        <td class="center">
            <a class="areaFeeDelete" href="javascript:;">删除</a>
        </td>
    </tr>
</script>

<script type="text/html" id="province_template">
    <li class="area-select-wrapper">
        <div class="area-select-head">
            <label for="J_Province_{id}" class="inline-label master-label">
                <input type="checkbox" onchange="regionHandler.proChange(this)" value="{id}" id="J_Province_{id}"
                       title="{provinceName}" name="chkArea"
                       class="input-check J_Province" style="cursor:default"/>{provinceName}
                <span id="child_count_{id}" style="color:red;display: none;">({childCount})</span>
            </label>
            {childrenShow}
        </div>
        <div class="area-select-body">
            {cities}
            <p><a href="javascript:;" class="close">×</a></p>
        </div>
    </li>
</script>
<script type="text/html" id="city_template">
    <label for="J_City_{id}">
        <input type="checkbox" name="chkArea" onchange="regionHandler.cityChange(this)" value="{id}" id="J_City_{id}" parent-id="{pId}" class="input-check J_City"/>{cityName}
    </label>
</script>

<script type="text/html" id="region_template">
    <div class="area_btn">
        <a href="javascript:;" class="btn btn-primary J_Submit">确定</a>
        <a href="javascript:;" class="btn J_cancel">取消</a>
    </div>
    <input type="hidden" id="reg_hd_deliveryType" value="{deliveryType}"/>
    <input type="hidden" id="reg_hd_stateIndex" value="{stateIndex}"/>
</script>


